﻿using Interfaces;
using Microsoft.AspNetCore.Http;

namespace Services;

public class CurrentUser : IUser
{
    private readonly IHttpContextAccessor _httpContextAccessor;

    public CurrentUser(IHttpContextAccessor httpContextAccessor)
    {
        _httpContextAccessor = httpContextAccessor;
    }

    public string? Id => _httpContextAccessor.HttpContext?.User?.FindFirst(nameof(IUser.Id))?.Value;

    public string? Name => _httpContextAccessor.HttpContext?.User?.FindFirst(nameof(IUser.Name))?.Value;
}
